<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="author" content="Wangrui">
    <script src="jquery-3.1.1.js"></script>
    <title>图片翻转</title>
    <style>
    *{
        box-sizing: border-box;
    }
   ul,li, h1{
        margin:0 ;
        padding:0;
        list-style: none;
    }
    .box{
        width:312px;
        margin:0;
        border:1px solid #ccc;
        box-shadow: 0 0 5px #ddd;
    }
    .box h1{
       height:40px;
       line-height: 40px;
       text-align: center;
       font-size:16px;
       color:#333;
       border-bottom:2px solid #333;
    }

    .box ul{
        padding:0 15px 10px 15px;
        overflow:hidden;
    }
    .box ul li{
        float:left;
        width:120px;
        height:75px;
        margin: 10px 10px 0 10px;
        position:relative;
    }
    .box li img{
        width:120px;
        height:75px;
        border:1px solid #eee;
        position: absolute;
        top:0;
        left:0;
        z-index:2;
    }
    .box li span{
        position: absolute;
        top:37px;
        left:0;
        width:120px;
        height: 0;
        border:1px solid #eee;
        background-color:#f93;
        text-align:center;
        line-height: 75px;
        font-size:14px;
        color:white;
        display: none;
        z-index:1;
    }

    </style>
</head>
<body>
    <div class="box">
        <h1>热门品牌推荐</h1>
        <hr>
        <ul>        
            <li><a href="#"><img src="images/11.jpg" alt=""><span>美肌</span></a></li>
            <li><a href="#"><img src="images/22.jpg" alt=""><span>美肌</span></a></li>
            <li><a href="#"><img src="images/33.jpg" alt=""><span>美肌</span></a></li>
            <li><a href="#"><img src="images/44.jpg" alt=""><span>美肌</span></a></li>
            <li><a href="#"><img src="images/55.jpg" alt=""><span>美肌</span></a></li>
            <li><a href="#"><img src="images/66.jpg" alt=""><span>美肌</span></a></li>
            <li><a href="#"><img src="images/77.jpg" alt=""><span>美肌</span></a></li>
            <li><a href="#"><img src="images/88.jpg" alt=""><span>美肌</span></a></li>
        </ul>
       
    </div>
</body>
</html>
<script>
$(function(){
    var ali = $('.box li');
    var aImg = $('.box li img');
    var aSpan = $('.box li span');
    ali.each(function(index){
        $(this).mouseover(function(){
            aImg.eq(index).stop();
            aSpan.eq(index).stop();
            //当鼠标进来图片高度变为0.当图片高度变为0 之后，紧接着让文字显示
            aImg.eq(index).css('z-index',1).animate({
                height:0,
                top:37,
            },80,function(){
                console.dir(this);
                // 图片隐藏
                $(this).hide();
                //动画结束后，让文字显示
                aSpan.eq(index).show().css('z-index',2).animate({
                    height:75,
                    top:0,
                },80);
            });
        });
        
        $(this).mouseout(function(){
            aImg.eq(index).stop();
            aSpan.eq(index).stop();
            // 鼠标出去，文字高度改为0，紧接着显示图片
            aSpan.eq(index).css('z-index',1).animate({
                height:0,
                top:37
            },80,function(){
                $(this).hide();
                // 显示图片
                aImg.eq(index).show().css('z-index',2).animate({
                    height:75,
                    top:0,
                },80)
            });
        });
    });
});

        })
    })
})

</script>